#define _CRT_SECURE_NO_WARNINGS 1
#include<string>
#include<iostream>

#include<list>
using namespace std;
string solve(string s, string t) {
    string s1; int s_end = s.size() - 1; int t_end = t.size() - 1;
    int n2 = 0; int n1 = 0;
    int i = 0; int j = 0;
    for (; s_end - i >= 0 && t_end - j >= 0; i++, j++)
    {
        n1 = s[s_end - i] - '0' + t[t_end - j] - '0';
        s1 += (n1 + n2) % 10 + '0';
        n2 = (n1 + n2) / 10;
    }
    if (s_end > t_end)
    {
        while (s_end - i >= 0)
        {
            n1 = s[s_end - i] - '0';
            s1 += (n1 + n2) % 10 + '0';
            n2 = (n1 + n2) / 10;
            i++;
        }
    }
    else {
        while (t_end - j >= 0)
        {
            n1 = t[t_end - j] - '0';
            s1 += (n1 + n2) % 10 + '0';
            n2 = (n1 + n2) / 10;
            j++;
        }
    }
    if (n2 != 0)
    {
        s1 += n2 + '0';
    }
    string::reverse_iterator it1 = s1.rbegin();
    while (it1 != s1.rend())
    {
        cout << *it1;
        it1++;
    }
    cout << endl;
    return s1;
}
ListNode* addInList(ListNode* head1, ListNode* head2) {
    ListNode* next1 = head1->next; string s;
    ListNode* next2 = head2->next; string t;
    ListNode* object = nullptr;
    while (next1 != head1) {
        s += next1->val + '0';
        next1 = next1->next;
    }
    while (next2 != head1) {
        t += next2->val + '0';
        next2 = next2->next;
    }
    string s1; int s_end = s.size() - 1; int t_end = t.size() - 1;
    int n2 = 0; int n1 = 0;
    int i = 0; int j = 0;
    for (; s_end - i >= 0 && t_end - j >= 0; i++, j++)
    {
        n1 = s[s_end - i] - '0' + t[t_end - j] - '0';
        s1 += (n1 + n2) % 10 + '0';
        n2 = (n1 + n2) / 10;
    }
    if (s_end > t_end)
    {
        while (s_end - i >= 0)
        {
            n1 = s[s_end - i] - '0';
            s1 += (n1 + n2) % 10 + '0';
            n2 = (n1 + n2) / 10;
            i++;
        }
    }
    else {
        while (t_end - j >= 0)
        {
            n1 = t[t_end - j] - '0';
            s1 += (n1 + n2) % 10 + '0';
            n2 = (n1 + n2) / 10;
            j++;
        }
    }
    if (n2 != 0)
    {
        s1 += n2 + '0';
    }
    //string s2;
    string::reverse_iterator it1 = s1.rbegin();
    while (it1 != s1.rend())
    {
        ListNode* newnode;
        newnode->val = *it1 - '0';
        it1++;
    }
}
int main()
{
    
    string s1=solve("1","99");
}